package com.factory.iamp.service.impl;

import com.factory.iamp.pojo.Sap;
import com.factory.iamp.service.SapService;
import com.factory.iamp.service.SapWebService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.jws.WebService;

@WebService(
        name = "SapWebService",
        targetNamespace = "http://service.iamp.factory.com",
        endpointInterface = "com.factory.iamp.service.SapWebService"
)
@Component
public class SapWebServiceImpl implements SapWebService {
    @Resource
    SapService sapService;

    @Override
    public String addSapData(
            String AUFNR, String AUART, String WERKS, String MATNR, String GAMNG, String GWEMG, String GSTRP,
            String GLTRP, String KDAUF, String KDPOS, String KUNNR
    ) {
        try {
            sapService.addSap(-1,
                    new Sap(AUFNR, AUART, WERKS, MATNR, GAMNG, GWEMG, GSTRP, GLTRP, KDAUF, KDPOS, KUNNR)
            );
            return "Success";
        } catch (Throwable throwable) {
            throwable.printStackTrace();
            return "Failure";
        }
    }
}
